const totalPages = 18;
let currentPage = 1;

function generatePagination() {
    const pagination = document.getElementById('pagination');
    const cont = document.getElementById('cont');
    pagination.innerHTML = '';

    for (let i = 1; i <= totalPages; i++) {
        const pageItem = document.createElement('a');
        pageItem.href = '#';
        pageItem.innerText = i;
        pageItem.classList.add('page-item');

        if (i === currentPage) {
            pageItem.classList.add('active');
        }

        pageItem.addEventListener('click', (e) => {
            e.preventDefault();
            currentPage = parseInt(e.target.innerText);
            generateContent();
            generatePagination();
        });

        pagination.appendChild(pageItem);


    }
}

function generateContent() {
    const cont = document.getElementById('cont');
    // content.innerHTML = `聚焦在${currentPage}`;
                            // 遍历li元素
                        // 获取所有的li元素
                        var liElements = document.querySelectorAll('ul#list li');
    const aList=["材料科学与工程学院教工党支部赴湖口开展主题党日活动","材料成型及控制工程专业顺利开展2024届本科毕业论文（设计）开题答辩工作","从党史中汲取力量，厚植爱党爱国情怀——材料科学与工程学院关工委和学生科举办“读懂...","材料科学与工程学院开展《机械制图》公开示范课活动","校党委书记李明斌深入材料学院调研"
                ,"规划启航，职引未来---材料科学与工程学院举办大学生职业规划大赛初赛","材料科学与工程学院召开学生教学信息反馈座谈会","材料科学与工程学院召开党委理论学习中心组（扩大）学习会","金属材料工程专业顺利开展2024届本科毕业论文（设计）开题答辩工作","中共材料科学与工程学院教工第二支部联合 新余学院机电工程学院党委开展 “沿着总书..."
                ,"材料科学与工程学院开展公开示范课活动","深度融合，焊接技术与工程专业开展校企毕业论文（设计）开题答辩论证及合作课程建设活动","材料学院邀请上海大学宋长江教授来校开展学术交流","材料科学与工程学院联合主办“第二届材料焊接与表面涂层防护技术研讨会”","落实学生工作责任，全面提升育人成效——我院召开辅导员、班主任工作会议"
                ,"材料科学与工程学院学子在第七届江西省大学生工程实践与创新能力大赛中获得优异成绩","我院举办第三期入党积极分子培训班","材料科学与工程学院开展课程目标达成情况评价 培训会","材料科学与工程学院教师参加“新一轮审核评估背景下高质量发展指标体系建设及高校管理...","材料科学与工程学院2023年10月第一期学术沙龙活动"
                ,"九江学院材料科学与工程学院第四次学代会成功召开","材料科学与工程学院实验室开展学科专业实验应急演练活动","用“心”育人 以“心”促“新”——材料科学与工程学院关工委举办2023级新生心理健康讲...","推进材料教育改革 助力人才培育培养——我院教师参加第十九届全国材料类基础课程教学研...","材料科学与工程学院开展应用型转型专题讲座",
                "材料科学与工程学院召开本科教育教学审核评估工作动员大会","材料科学与工程学院开展毕业生简历制作指导专题讲座","材料科学与工程学院召开2024届就业工作启动会","材料科学与工程学院召开党员大会","材料科学与工程学院教师赴新余参加江西省理化检验人员技术培训班并顺利结业"
                ,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45
                ,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
                ,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75
                ,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90
                ,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105
                ,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120
                ,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135
                ,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150
                ,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165
                ,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180
                ,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195
                ,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210
                ,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225
                ,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240
                ,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
                ,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270
            ]
    const spanList=["[2023-04-17]","[2023-04-14]","[2023-04-10]","[2023-04-08]","[2023-03-30]"
                   ,"[2023-03-30]","[2023-03-28]","[2023-03-26]","[2023-03-24]","[2023-03-23]"
                   ,"[2023-03-23]","[2023-03-20]","[2023-03-20]","[2023-03-20]","[2023-03-20]"
                   ,"[2023-11-06]","[2023-11-03]","[2023-11-01]","[2023-10-30]","[2023-10-30]"
                   ,"[2023-10-27]","[2023-10-27]","[2023-10-24]","[2023-10-24]","[2023-10-19]"
                   ,"[2023-10-19]","[2023-10-13]","[2023-10-13]","[2023-10-12]","[2023-10-09]"
                   ,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45
                   ,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
                   ,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75
                   ,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90
                   ,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105
                   ,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120
                   ,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135
                   ,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150
                   ,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165
                   ,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180
                   ,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195
                   ,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210
                   ,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225
                   ,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240
                   ,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
                   ,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270
    ]
    for (var i = (currentPage-1)*15,j=0; j < liElements.length; j++,i++) {
        // 获取a和span元素
        var aElement = liElements[j].querySelector('a');
        var spanElement = liElements[j].querySelector('span');
    
        // 设置a和span元素的文本内容
        aElement.textContent = aList[i] // 将'自定义文本'替换为你想要设置的文本
        spanElement.textContent = spanList[i]; // 将'自定义文本'替换为你想要设置的文本
    }
}

generateContent();
generatePagination();

